package com.focus.xyz.union.pages.backend.tables;

import com.focus.xyz.core.common.keyword.Action;
import com.focus.xyz.core.pages.BaseTable;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

/**
 * Created by chenmeng on 2016/4/18.
 */
public class WebSiteTable extends BaseTable {
    @FindBy(xpath = "//*[@id=\"list00_table\"]")
    private WebElement webSiteTable;
    private static final String LINK_XPATH = "td[12]/a";

    public WebSiteTable(WebDriver driver,Action action){
        super(action);
        PageFactory.initElements(driver,this);
    }

    @Override
    protected By getLinkLocator() throws Exception {
        return By.xpath(LINK_XPATH);
    }

    @Override
    protected By getLocator(int index) throws Exception {
        return By.xpath("td[" + index + "]/div");
    }

    public void linkApprovalByName(String name, String linkName) throws Exception {
        selectRowAndClickLink(webSiteTable, name, linkName);
    }
}
